package com.xianggg.xservers.weixin.sdk;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class ApiUrl {
    private final static String ENCODE = "UTF-8";

    public static String getOAuth2Url(String appID,String redirectUri,String scope,String state){
        try {
            redirectUri = URLEncoder.encode(redirectUri,ENCODE);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appID+"&redirect_uri="+redirectUri+"&response_type=code&scope="+scope+"&state="+state+"#wechat_redirect";
    }

    public static String getOAuth2AccessTokenUrl(String appID,String secret,String code){
        return "https://api.weixin.qq.com/sns/oauth2/access_token?appid="+appID+"&secret="+secret+"&code="+code+"&grant_type=authorization_code";
    }

}
